package com.zz.intercetpor;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Component
public class LoginInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

        Object loginUser = request.getSession().getAttribute("param");
        System.out.println(loginUser);
        if (loginUser != null) {
            System.out.println(loginUser);
            return true;
        }
        response.sendRedirect("/site/login.html");
        return false;
    }
}
